//package com.example.springboot.config;
//
//import com.example.springboot.service.UserService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//
//import javax.sql.DataSource;
//
//
//@Configuration
//@EnableWebSecurity
//public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
//
//    @Autowired
//    UserService userService;
//
//    @Autowired
//    DataSource dataSource;
//
//    @Override
//    protected void configure(HttpSecurity http) throws Exception {
//        http
//                .authorizeRequests()
//                .antMatchers("/css/**", "/js/**","/img/**", "/music/**", "/themes/**").permitAll()
//                    .antMatchers("/page/index", "/page/toRegister").permitAll()
//                    .anyRequest().authenticated()
//                    .and()
//                .formLogin()
//                    .defaultSuccessUrl("/page/toMenu")
//                    .loginPage("/page/toLogin")
//                    .permitAll()
//                    .and()
//
////                    .csrf().disable()
//                .logout()
//                    .permitAll();
//
//    }
//
//    @Autowired
//    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
//        auth
//                .inMemoryAuthentication()
//                .withUser("user").password("password").roles("USER");
////                .jdbcAuthentication()
////                .dataSource(dataSource)
////                .usersByUsernameQuery(
////                  "select username, password from test where username=?"
////                );
//    }
//
////    @Override
////    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
////        auth.userDetailsService(userService).passwordEncoder(new PasswordEncoder() {
////            @Override
////            public String encode(CharSequence charSequence) {
////                return DigestUtils.md5DigestAsHex(charSequence.toString().getBytes());
////            }
////
////            /**
////             * @param charSequence 明文
////             * @param s 密文
////             * @return
////             */
////            @Override
////            public boolean matches(CharSequence charSequence, String s) {
////                return s.equals(DigestUtils.md5DigestAsHex(charSequence.toString().getBytes()));
////            }
////        });
////    }
//
//}
//
